# 设置目标文件夹路径
$targetFolder = "F:\MedAi\pancreas_all"
# $targetFolder = "D:\BaiduNetdiskDownload\2024.7.9勾画"

# 获取所有三级目录
$thirdLevelFolders = Get-ChildItem -Path $targetFolder -Recurse -Directory | 
                     Where-Object { $_.FullName.Split('\').Count -eq ($targetFolder.Split('\').Count + 3) }

foreach ($folder in $thirdLevelFolders) {
    # 获取该目录下的所有 .nii.gz 文件
    $niiFiles = Get-ChildItem -Path $folder.FullName -Filter "*.nii.gz"

    # 检查文件数量
    if ($niiFiles.Count -lt 2) {
        # 打印出文件夹名称
        Write-Host "文件夹 '$($folder.FullName)' 中只找到 $($niiFiles.Count) 个 .nii.gz 文件"
    }
}
